<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <!-- 可被 K 整除的最小整数 -->
    <script>
      var smallestRepunitDivByK = function (k) {
        if (k == 1) return 1
        if (k % 2 == 0 || k % 5 == 0) return -1
        let testNum = 1
        let ans = 1
        while (testNum != 0) {
          testNum = (testNum * 10 + 1) % k
          ans++
        }
        return ans
      }
      console.log(smallestRepunitDivByK(1))
    </script>
  </body>
</html>
